Thuật toán biểu diễn số thực bằng liên phân số chính tắc Liên_phân_số

Thuật toán sau là một cách đơn giản để biểu diễn số thực bất kì dưới dạng liên phân số chính tắc:

Cho số thực r, ký hiệu i là phần nguyên của r, f là phần thập phân của r. Biểu diễn liên phân số của r là [i; a1, a2,...], trong đó [a1; a2,...] là dạng biểu diễn liên phân số của 1/f. Nếu như f=0 thì thuật toán dừng lại, trong trường hợp f khác 0, ta lặp lại các bước trên với r thay bằng 1/f.

Ví dụ cho r= 4,345. Như vậy i= 4, f= 0,345.Bảng sau mô tả các bước tìm biểu diễn liên phân số của r.

Tìm dạng biểu diễn liên phân số của 4,345
Số thựcPhần nguyên (floor)Phần thập phânRút gọn của phần thập phânNghịch đảo của f {\displaystyle f} Rút gọn của 1 / f {\displaystyle 1/f}
r = 4 , 345 {\displaystyle r=4,345\,} i = 4 {\displaystyle i=4\,} f = 4 , 345   ( 4 69 200 ) − 4 {\displaystyle f=4,345\ \left(4{\tfrac {69}{200}}\right)-4\,} = 0 , 345   ( 69 200 ) {\displaystyle =0,345\ \left({\tfrac {69}{200}}\right)\,} 1 / f = 1 / 0 , 345   ( 200 69 ) {\displaystyle 1/f=1/0,345\ \left({\tfrac {200}{69}}\right)\,} = 2 , 899   ( 2 62 69 ) {\displaystyle =2,899\ \left(2{\tfrac {62}{69}}\right)\,}
r = 2 , 899 {\displaystyle r=2,899\,} i = 2 {\displaystyle i=2\,} f = 2 , 899   ( 2 200 69 ) − 2 {\displaystyle f=2,899\ \left(2{\tfrac {200}{69}}\right)-2\,} = 0 , 899   ( 62 69 ) {\displaystyle =0,899\ \left({\tfrac {62}{69}}\right)\,} 1 / f = 1 / 0 , 899   ( 69 62 ) {\displaystyle 1/f=1/0,899\ \left({\tfrac {69}{62}}\right)\,} = 1 , 113   ( 1 7 62 ) {\displaystyle =1,113\ \left(1{\tfrac {7}{62}}\right)\,}
r = 1 , 113 {\displaystyle r=1,113\,} i = 1 {\displaystyle i=1\,} f = 1 , 113   ( 1 7 62 ) − 1 {\displaystyle f=1,113\ \left(1{\tfrac {7}{62}}\right)-1\,} = 0 , 113   ( 7 62 ) {\displaystyle =0,113\ \left({\tfrac {7}{62}}\right)\,} 1 / f = 1 / 0 , 113   ( 62 7 ) {\displaystyle 1/f=1/0,113\ \left({\tfrac {62}{7}}\right)\,} = 8 , 857   ( 8 6 7 ) {\displaystyle =8,857\ \left(8{\tfrac {6}{7}}\right)\,}
r = 8 , 857 {\displaystyle r=8,857\,} i = 8 {\displaystyle i=8\,} f = 8 , 857   ( 8 6 7 ) − 8 {\displaystyle f=8,857\ \left(8{\tfrac {6}{7}}\right)-8\,} = 0 , 857   ( 6 7 ) {\displaystyle =0,857\ \left({\tfrac {6}{7}}\right)\,} 1 / f = 1 / 0 , 857   ( 7 6 ) {\displaystyle 1/f=1/0,857\ \left({\tfrac {7}{6}}\right)\,} = 1 , 167   ( 1 1 6 ) {\displaystyle =1,167\ \left(1{\tfrac {1}{6}}\right)\,}
r = 1 , 167 {\displaystyle r=1,167\,} i = 1 {\displaystyle i=1\,} f = 1 , 167   ( 1 1 6 ) − 1 {\displaystyle f=1,167\ \left(1{\tfrac {1}{6}}\right)-1\,} = 0 , 167   ( 1 6 ) {\displaystyle =0,167\ \left({\tfrac {1}{6}}\right)\,} 1 / f = 1 / 0 , 167   ( 6 1 ) {\displaystyle 1/f=1/0,167\ \left({\tfrac {6}{1}}\right)\,} = 6 , 000   ( 1 6 1 ) {\displaystyle =6,000\ \left(1{\tfrac {6}{1}}\right)\,}
r = 6 , 000 {\displaystyle r=6,000\,} i = 6 {\displaystyle i=6\,} f = 6 , 000   ( 6 ) − 6 {\displaystyle f=6,000\ \left(6\right)-6\,} = 0 , 000 {\displaystyle =0,000\,} Dừng
Biểu diễn liên phân số của 4,345 là [4; 2, 1, 8, 1, 6]
4 , 345 = 4 + 1 2 + 1 1 + 1 8 + 1 1 + 1 6 {\displaystyle 4,345=4+{\cfrac {1}{2+{\cfrac {1}{1+{\cfrac {1}{8+{\cfrac {1}{1+{\cfrac {1}{6}}}}}}}}}}}

Số 4,345 là một số hữu tỉ, do đó biểu diễn liên phân số của nó hữu hạn.

Tài liệu tham khảo

WikiPedia: Liên_phân_số http://www.research.att.com/~njas/sequences/A13359... http://sputsoft.com/2009/11/continued-fractions-an... http://demonstrations.wolfram.com/ContinuedFractio... http://demonstrations.wolfram.com/ContinuedFractio... http://mathworld.wolfram.com/ContinuedFraction.htm... http://vn.answers.yahoo.com/question/index;_ylt=Ak... http://www.math.sunysb.edu/~tony/whatsnew/column/a... http://www.cut-the-knot.org/blue/ContinuedFraction... http://www.linas.org/math/chap-gap/chap-gap.html https://id.loc.gov/authorities/subjects/sh85051149